const toQuery = function(obj) {
    if (obj) {
      let q = "?";
      Object.keys(obj).forEach((key, value) => {
        if (q.length > 1) q += "&";
        q += `${key}=` + encodeURIComponent(obj[key] ?? "");
      });
      return q;
    } else {
      return "";
    }
  };

export {
    toQuery
}